package com.alveole.events;

import java.util.List;

import com.alveole.tools.Logger;


public class Event {
	protected String command;
	protected String target;
	protected String data;
	
	public Event()
	{
		
	}
	public Event(Event event)
	{
		init(event.command,event.target,event.data);
	}	
	public Event(String command, String target, String data)
	{
		init(command,target,data);
	}
	public Event init(String command, String target, String data) {
		this.command = command;
		this.target = target;
		this.data = data;
		return this;
	}
	public String getCommand() {
		return command;
	}
	public void setCommand(String command) {
		this.command = command;
	}

	public String getTarget() {
		return target;
	}
	public void setTarget(String target) {
		this.target = target;
	}
	public String getData() {
		return data;
	}
	public void setData(String data) {
		this.data = data;
	}
	public String quote(String value)
	{
		return "\""+value+"\"";
	}
	public static String EventListAsJSON(List<ServerEvent> answers)
	{
	  	String resp="";
	  	resp += ("{");
	  	resp += ("\"events\":");
	  	resp += ("[");
	  	for (int i=0; i<answers.size() ;i++)
	  	{ //resp +="{\"command\":\"a\"}";
	  		resp += answers.get(i).getJSON();
	  		if (i!=answers.size()-1) resp += ",";
	  	}
	  	resp += ("]");
	  	resp+="}";
		Logger.log(Logger.USERRUN, " " + resp);
	  	
	  	return resp;
	}
}
